<template>
  <a-popconfirm
    title="确认删除该云端设备数据吗？"
    ok-text="确认"
    cancel-text="取消"
    @confirm="confirm"
    @cancel="cancel"
  >
    <a-button type="danger">删除</a-button>
  </a-popconfirm>
</template>

<script lang="ts">
import { defineComponent, inject } from "vue";
import { deleteDeviceData } from "@/controller/Data";

export default defineComponent({
  name: "DeleteDataConfirm",
  props: {
    id: {
      type: String,
      required: true,
    },
  },
  setup(props) {
    const refresh: Function = inject("refresh") ?? new Function();
    const confirm = async () => {
      await deleteDeviceData(props.id);
      refresh();
    };
    const cancel = () => {
      console.log("cancel");
    };
    return { confirm, cancel };
  },
});
</script>

<style scoped lang="scss"></style>
